#include <QtGui>
#include "CamTestMain.h"

//Constructor
CamTestMain::CamTestMain(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //QString *tmpStr = new QString;
    QLabel *LabelFileName           = new QLabel(tr("Nom du fichier:"));
    QLabel *LabelFileStatus         = new QLabel(tr("Etat :"));
    QLabel *LabelCmdStrTitle        = new QLabel(tr("Commandes stream"));
    QLabel *LabelCmdSetGetTitle     = new QLabel(tr("Commandes configuration"));
    QLabel *LabelCmdGrabReadTitle   = new QLabel(tr("Commandes Read/Grab"));
    QLabel *LabelCmdFullGrab        = new QLabel(tr("Commande automatise"));

    EditFileName = new QLineEdit;
    QLabel *LabelStatus = new QLabel;
    EditFileName->setText("/Dev/USBDriva0");
    LabelStatus->setText("Ferme");

    QPushButton *PBtnOpenFile   = new QPushButton(tr("Ouvrir"));
    //PBtnOpenFile = new QPushButton(0);
    //tmpStr->setRawData("Ouvrir",6);
    //PBtnOpenFile->setObjectName(tmpStr);
    //PBtnOpenFile->setText("Ouvrir");
    QPushButton *PBtnCloseFile  = new QPushButton(tr("Fermer"));
    QPushButton *PBtnSet        = new QPushButton(tr("Set"));
    QPushButton *PBtnGet        = new QPushButton(tr("Get"));
    QPushButton *PBtnGrab       = new QPushButton(tr("Grab"));
    QPushButton *PBtnRead       = new QPushButton(tr("Lecture"));
    QPushButton *PBtnTakePic    = new QPushButton("Capturer",this);
    QPushButton *PBtnStreamOn   = new QPushButton(tr("StreamOn"));
    QPushButton *PBtnStreamOff  = new QPushButton(tr("StreamOff"));

    PBtnCloseFile->setEnabled(false);


//! [constructor and input fields]

//! [layout]
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(LabelFileName, 0, 0);
    mainLayout->addWidget(EditFileName, 0, 1);
    mainLayout->addWidget(LabelFileStatus, 1, 0);
    mainLayout->addWidget(LabelStatus, 1, 1);
    mainLayout->addWidget(PBtnOpenFile, 3, 0);
    mainLayout->addWidget(PBtnCloseFile, 3, 1);
    mainLayout->addWidget(LabelCmdStrTitle, 4, 0);
    mainLayout->addWidget(PBtnStreamOn, 5, 0);
    mainLayout->addWidget(PBtnStreamOff, 5, 1);
    mainLayout->addWidget(LabelCmdSetGetTitle, 6, 0);
    mainLayout->addWidget(PBtnSet, 7, 0);
    mainLayout->addWidget(PBtnGet, 7, 1);
    mainLayout->addWidget(LabelCmdGrabReadTitle, 8, 0);
    mainLayout->addWidget(PBtnGrab, 9, 0);
    mainLayout->addWidget(PBtnRead, 9, 1);
    mainLayout->addWidget(LabelCmdFullGrab, 10, 0);
    mainLayout->addWidget(PBtnTakePic, 11, 0);

    //QSignalMapper *mapper = new QSignalMapper( this );
    //mapper->setMapping(PBtnTakePic, "TakePic");
    this->connect(this->ui->pushButton, SIGNAL(clicked()), this, SLOT(buttonClicked) );


//![setting the layout]
    setLayout(mainLayout);
    setWindowTitle(tr("Cam Tester App"));
}

void CamTestMain::buttonClicked()
{
    LabelStatus->setText("ALLELUYA");
}
